<div class="loading-container"><div class="loader"></div></div>

<div class="loading-waiter">
	<div class="loader">
		<div class="texting">请稍后...</div>
		<div class="spinner">
		  <div class="rect1"></div>
		  <div class="rect2"></div>
		  <div class="rect3"></div>
		  <div class="rect4"></div>
		  <div class="rect5"></div>
		</div>
	</div>
</div>

<div class="wrapper wrapper-shadow wrapper-list"> 
	<!-- list data wrapper -->
	<div class="result-wrapper no-padding">
   	<div class="result-body">
   		<div class="tabs">
      	<ul class="nav nav-tabs widget no-margin-bottom">
        	<li class="active"> 
         		<a href="#tab-content" data-toggle="tab"> 
         			<span class="menu-icon"><i class="fa fa-bar-chart"></i></span> 班级到课表
           	</a>
         	</li>
        </ul>
        <div class="tab-content no-border xs-padding">
					<div class="tab-pane active" id="tab-content" style="padding:10px 0;">
           	<div class="search-panel" style="margin-bottom: 10px;">
           		<form class="form-inline" id="search-form" action="/miwawa/{dbname}/common/procedure/call" method="post">
           			<div class="form-group">
							    <label for="from">统计时间：</label>
							    <div class="input-group date date-selector">
										<input id="from" type="text" class="form-control" placeholder="开始时间"> 
										<span class="input-group-addon">
											<span class="fa fa-calendar"></span>
										</span>
									</div>
									<span>-</span>
									<div class="input-group date date-selector">
										<input id="over" type="text" class="form-control" placeholder="截止时间"> 
										<span class="input-group-addon">
											<span class="fa fa-calendar"></span>
										</span>
									</div>
									<button type="button" class="btn btn-warning" onclick="handlerReset();">重置</button>
							  </div>
							  
							  <div class="vertical-space space-5"></div>
							  
							  <div class="form-group">
									<label for="from">负责老师：</label>
							    <div class="input-group">
										<select id="teacher" multiple class="chosen-select" style="width: 399px;" data-entity="com.app.miwawa.api.eam.entity.view.TeacherView">
										</select>
										<span class="input-group-btn">
											<button type="button" class="btn btn-addon" onclick="handlerClear('#teacher');"><i class="fa fa-trash"></i></button>
										</span>
									</div>
									<button type="button" class="btn btn-primary" onclick="handlerQuery();">统计</button>
									<button type="button" class="btn btn-success" onclick="handlerExport();">导出</button>
								</div>
								
           		</form>
           	</div>
           	<table data-ajax="handlerQuery" 
           				 data-method="post" 
           				 data-id-field="id" 
           				 data-unique-id="id" 
           				 data-pagination="true" 
           				 data-check-on-init="true" 
           				 data-click-to-select="true" 
           				 data-side-pagination="server" 
           				 data-mobile-responsive="true" 
           				 data-event-onload="handlerSuccess" 
           				 id="table-report-resign" class="bootstrap-table">
							<thead>
								<tr>
									<th data-checkbox="true"></th>
									<th data-field="lesson" 			data-align="center" data-formatter="renderIndex">序号</th>
									<th data-field="classestype" 	data-align="center">课程</th>
									<th data-field="classes" 			data-align="center">班级名称</th>
									<th data-field="classesdate"	data-align="center">上课时间</th>
									<th data-field="teacher" 			data-align="center">老师</th>
									<th data-field="students" 		data-align="center">班级人数</th>
									<th data-field="checked" 			data-align="center">实到人数</th>
									<th data-field="chkpert" 			data-align="center" data-formatter="renderChkpert">到课率</th>
									<th data-field="promise"  		data-align="center">预约试听</th>
									<th data-field="comming"  		data-align="center">实际到店</th>
									<th data-field="cmgpert" 			data-align="center" data-formatter="renderCmgpert">试听到课率</th>
								</tr>
							</thead>
						</table>
        	</div>
      	</div>
    	</div>
   	</div>
	</div>

	<!-- form editor wrapper -->
	<div class="editor-wrapper">
		
	</div>
</div>
<!-- PAGE CONTENT END =============================================== -->

<form id="export-form" action="/miwawa/{dbname}/common/procedure/export" method="post">
	<input type="hidden" name="name" value="班级到课表"/>
</form>

<!-- Javascript ===================================================== -->
<script src="/miwawa/resources/lib/miwawa/1.0.2/js/core/requirejs/require.js"></script>

<script type="text/javascript">
<!--
	jQuery(function(){
		require(['/miwawa/resources/lib/miwawa/1.0.2/js/core/module/app/simple.js','jquery.plugin.form'],function(simple,form){
			simple(['registerForm','registerTable','registerWidget']);
			
			form.datepicker(".date-selector",{defaultDate:null});
			
			form.tooltip("[data-toggle='tooltip']");
			
			form.chosen("#teacher").select("#teacher",{querys:{"invalid_EQ":"F"}});
		});
	});
	
	// 重置查询条件
	function handlerReset(){
		jQuery("#search-form").resetForm();
	}
	
	// 导出
	function handlerExport(){
		var action = jQuery("#export-form").attr("action").replace("{dbname}", dbname);
		jQuery("#export-form").attr("action", action);
		jQuery(":hidden[name='params[html]']","#export-form").remove();
		jQuery("#export-form").append('<input type="hidden" name="params[html]"/>');
		jQuery(":hidden[name='params[html]']","#export-form").val(jQuery(".fixed-table-body").html());
		jQuery("#export-form")[0].submit();
	}
	
	// 统计
	function handlerQuery(params){
		if(params){
			var _opts = {};
			if(typeof(params.data) == "string") _opts = jQuery.parseJSON(params.data);
			
			jQuery.ajaxsend({
				url:"/miwawa/{dbname}/common/procedure/call".replace("{dbname}",dbname),
				data:{
					"name":"pro_report_classes_month",
					"params":{
						"_from":jQuery("#from").val(),
						"_over":jQuery("#over").val(),
						"_teacher":jQuery.utils.toSQLEscapeValue(jQuery("#teacher").val()),
						"_offset":_opts.offset,
						"_limit":_opts.limit
					}
				},
				beforeSend:function(){
					jQuery.utils.loading("正在准备统计数据，请稍后...", "show");
					return true;
				},
				success:function(data){
					params.success(data);
					params.complete();
					jQuery.utils.loading(null, "hide");
				}
			});
		}else{
			jQuery("#table-report-resign").bootstrapTable("refresh");
		}
	}
	
	function renderIndex(value, row, index){
		var _options = jQuery("#table-report-resign").bootstrapTable("getOptions");
		var _current = _options.pageNumber;
		var _pagsize = _options.pageSize;
		return (_current-1)*_pagsize + (index+1);
	}
	
	function renderChkpert(value, row, index){
		return row.students && row.students > 0 ? (row.checked/row.students*100).toFixed(2)+'%' : '0%'; 
	}
	
	function renderCmgpert(value, row, index){
		return row.promise && row.promise > 0 ? (row.comming/row.promise*100).toFixed(2)+'%' : '0%'; 
	}
//-->
</script>
